package com.huahua.api.controller.entertainment;

import com.huahua.api.entity.entertainment.param.PalmReadingParam;
import com.huahua.api.service.entertainment.PalmReadingService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * 看手相控制器
 *
 * @author System
 * @date 2025-06-23
 */
@RestController
@RequestMapping("/entertainment/palmReading")
@RequiredArgsConstructor(onConstructor = @__(@Lazy))
public class PalmReadingController {

    private final PalmReadingService palmReadingService;

    /**
     * 分析手相
     *
     * @param param 包含图片URL的参数
     * @return 流式返回手相分析结果
     */
    @PostMapping(value = "/analyze", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> analyzePalm(@RequestBody PalmReadingParam param) {
        return palmReadingService.analyzePalm(param.getImageUrl());
    }
}
